<?php
namespace wechat;

class Ticket extends Base
{
	
	/**
	* 创建永久二维码ticket 	2017-10-15
	*/
	public function getticket($data,$access_token,$attach = array()){
		$url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=$access_token";
		$result = httpdata($url,$data);
		
		!isset($attach['uid']) && $attach['uid'] = 0;
		apilog($attach['uid'], 'wechat', 'getqrocdeticket', $url, $data, $result);
		
		return $result;
	}
	
	/**
	 * 通过ticket换取二维码 	2017-03-09
	 */
	public function getqrcode($ticket,$attach = array()){
		$url = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=$ticket";  //通过ticket换取二维码			
		$img = file_get_contents($url);
	
		!isset($attach['uid']) && $attach['uid'] = 0;
		apilog($attach['uid'], 'wechat', 'getqrcode', $url, '', '');
		
		return $img;
	}
	
}